package com.ecb.business.controller;

import com.ecb.business.dto.api.ApiResult;
import com.ecb.business.dto.evidence.EvidenceDTO;
import com.ecb.business.dto.evidence.QueryEvidenceDTO;
import com.ecb.business.service.EvidenceManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("evidence")
@Api(tags = "存证管理")
public class EvidenceManageController {

    @Autowired
    EvidenceManageService evidenceManageService;

    @GetMapping("getAllEvidenceByRole")
    @ApiOperation(value = "根据角色获取证书",notes = "角色分为组织、节点与用户")
    public ApiResult getAllEvidenceByRole(@RequestBody QueryEvidenceDTO queryDTO){
        return ApiResult.T(evidenceManageService.getAllEvidenceByRole(queryDTO));
    }

    @PostMapping("getEvidenceById")
    @ApiOperation(value = "根据id获取证书",notes = "")
    public ApiResult getEvidenceById(@RequestBody QueryEvidenceDTO queryEvidenceDTO){
        return ApiResult.T(evidenceManageService.getEvidenceById(queryEvidenceDTO));
    }

    @PostMapping("addEvidence")
    @ApiOperation(value = "新增证书",notes = "")
    public ApiResult addEvidence(@RequestBody EvidenceDTO evidenceDTO ){
        return ApiResult.T(evidenceManageService.addEvidence(evidenceDTO));
    }
    @PostMapping("updateEvidence") // 更新证书
    @ApiOperation(value = "",notes = "")
    public ApiResult updateEvidence(@RequestBody EvidenceDTO evidenceDTO ){
        return ApiResult.T(evidenceManageService.updateEvidence(evidenceDTO));
    }
    @PostMapping("deleteEvidence")
    @ApiOperation(value = "删除证书",notes = "")
    public ApiResult deleteEvidence(@RequestBody EvidenceDTO evidenceDTO  ){
        return ApiResult.T(evidenceManageService.deleteEvidence(evidenceDTO));
    }
}
